package com.ctbu.tourism.controller.restful;

import com.ctbu.tourism.entity.Result;
import com.ctbu.tourism.service.CommentService;
import com.ctbu.tourism.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CommentController {
    @Autowired
    CommentService commentService;

    @GetMapping("/comment/{pid}")
    Result getCommentByPID(@PathVariable("pid") Integer pid){
        return ResultUtil.success(commentService.getCommentByPID(pid));
    }
    @PutMapping("/comment/add")
    Result addComment(@RequestParam("pid") Integer pid,@RequestParam("content") String content,@RequestParam("commentator") Integer commentator,@RequestParam("becommented") Integer becommented,@RequestParam("type") String type){
        return ResultUtil.success(commentService.addComment(pid,content,commentator,becommented,type));
    }
    @GetMapping("/message/comment")
    Result getMessageComment(@RequestParam("uid") Integer uid){
        return ResultUtil.success(commentService.getMessageByUID(uid));
    }
    @PutMapping("/message/comment/update/status")
    Result updateCommentStatus(@RequestParam("id") Integer id){
        return ResultUtil.success(commentService.updateCommentStatus(id));
    }
}
